import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.util.Random;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;



@SuppressWarnings("serial")
class BackgroundPanel extends JPanel {

//    private void doDrawing(Graphics g) {
//	    Graphics2D g2d = (Graphics2D) g;
//        g2d.setColor(Color.blue);
//      
//        Dimension size = getSize();
//        Insets insets = getInsets();
//
//        int w = size.width - insets.left - insets.right;
//        int h = size.height - insets.top - insets.bottom;
//
//        Random r = new Random();
//
//        for (int i = 0; i < 1000; i++) {
//
//            int x = Math.abs(r.nextInt()) % w;
//            int y = Math.abs(r.nextInt()) % h;
//            g2d.drawLine(x, y, 500, 500);
//        }
//       
//    }
//    public void paint(Graphics g){
//	    Graphics2D g2 = (Graphics2D) g;
//
//	    Image img1 = Toolkit.getDefaultToolkit().getImage("image\\background.png");
//	    g2.drawImage(img1, 0, 0, this);
//	    g2.finalize();
//	  }
//    @Override
//    public void paintComponent(Graphics g) {
//
//        super.paintComponent(g);
//     //  doDrawing(g);
//      //  paint(g);
//    }
	 Image img;
	    public BackgroundPanel()
	    {
	        // Loads the background image and stores in img object.
	    	String path = System.getProperty("user.dir") +"\\images\\bg.jpg";
	        img = Toolkit.getDefaultToolkit().createImage(path);
	    	System.out.println("hello = " +path);
	    	System.out.println("hello = " +path);
	    }

	    public void paint(Graphics g)
	    {
	        // Draws the img to the BackgroundPanel.
	        g.drawImage(img, 10, 10, null);
	    }
}

@SuppressWarnings("serial")
public class Points extends JFrame {

	/**
	 * @param args
	 */
	public Points() {

        initUI();
    }

    private void initUI() {
        
        setTitle("Points");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        
        add(new BackgroundPanel());
        setSize(900, 900);

        setLocationRelativeTo(null);
	    	    
	    
    }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		
		
		SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {

                Points ps = new Points();
                ps.setVisible(true);
            }
        });
	}

}
